<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>ECSHOP 管理中心 - 添加类目属性 </title>
	<link href="<%=request.getContextPath()%>/css/system/general.css" rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath()%>/css/system/main.css" rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath()%>/css/system/category.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${ctx}/js/checkFrameSet.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.3.2.min.js"></script>
	<script type="text/javascript">
       var contextPath = "${ctx}";
    </script>
	<script type="text/javascript" src="${ctx}/js/category-view.js"></script>
	<script language="JavaScript">
	 $(document).ready(findCategoryList); 
	 function submitOperation(){
		document.getElementById("submitBt").disabled=true;
		if($("#name").val()=="" || $.trim($("#name").val())==""){
		    $("#nameTip").show();
		    $("#name").focus();
		    document.getElementById("submitBt").disabled=false;
	        return false;
		}
	    return true;
	 }
	 function addCandidateValue(){
	    $("#brandModel-table tr:last").after("<tr><td> <input type=\"text\"  size=\"20\" maxlength=\"32\" name=\"candidateValue\"/>  状态 <select name=\"candidateValueStatus\"><option selected=\"selected\" value=\"1\">启用</option><option value=\"0\">停用</option></select>  <a onclick=\"removeCandidateValue(this)\" href=\"javascript:;\" title=\"移除属性候选值\">[移除]</a></td></tr>");	
	 }
	 function removeCandidateValue(obj){
	    $(obj.parentNode.parentNode).remove();
	 }
	 function onchangeDisplayType(typeValue){
	    if(typeValue!="${CATEGORY_ATTRIBUTE_DISPLAY_TYPE_INPUTTEXT}"){
	       $("#candidateTrId").show();
	    }else{
	       $("#candidateTrId").hide();
	    }
	 }
	</script>

      <style>
       <!--
        body{
      	   font-size:13px;
      	}
       -->
      	  
      </style> 
</head>
<body>
<h1>
<c:if test="${USER_OPERATION_URIS_MAP['/system/categoryAttribute/list']!=null}">
<span class="action-span"><a href="<%=request.getContextPath()%>/system/categoryAttribute/list?categoryId=${categoryId}">类目属性列表</a></span>
</c:if>
<span class="action-span1"><a href="#">ECSHOP 管理中心</a>  - 添加类目属性 </span>
<div style="clear:both"></div>
</h1>

<c:if test="${!empty OPERATION_FLAG}">
<c:choose>
  <c:when test="${OPERATION_FLAG==OPERATION_FLAG_TRUE}">
  <ul class="actionMessage">
    <li>操作成功
    </li>
  </ul>
  </c:when>
  <c:when test="${OPERATION_FLAG==OPERATION_FLAG_FALSE}">
  <ul class="actionMessage">
    <li>操作失败
    </li>
  </ul>
  </c:when>
</c:choose>
</c:if>
<div class="main-div">
  <form:form modelAttribute="categoryAttribute" action="${ctx}/system/categoryAttribute" method="post" name="theForm" id="theForm" onsubmit="return submitOperation();">
  <input type="hidden" name="p_cate_id" id="p_cate_id" value="${categoryId}"/>
  <input type="hidden" name="is_leaf" id="is_leaf" value="1"/>
  <table width="100%" id="general-table">
      <tr id="nameTip" style="display:none">
        <td class="label"></td>
        <td class="news-operation-tip">请输入属性名称</td>
      </tr>
      <tr>
        <td class="label">属性名称：</td>
        <td>
          <input type="text" name="name" id="name" maxlength="20" value="" size="27" /> <font color="red">*</font>        </td>
      </tr>
      <!-- 
      <tr>
        <td class="label">品牌编码：</td>
        <td><input type="text" name="code" id="code" maxlength="20" value="" size="27" /></td>
      </tr>
      <tr>
        <td class="label">品牌logo：</td>
        <td><input type="file" name="logo" id="logo"/></td>
      </tr>
      <tr>
        <td class="label">品牌关键字：</td>
        <td><input type="text" name="keyWord" id="keyWord" value=""/></td>
      </tr>
      <tr>
        <td class="label">品牌url：</td>
        <td><input type="text" name="htmlUrl" id="htmlUrl" value=""/></td>
      </tr>
       -->
      <tr>
        <td class="label">所属目录：</td>
        <td>
	       <div class="cascading-container">
		    <ol id="J_OlCascadingList">
		      <li id="l_1" class="root">
		        <ul id="u_1">
		        <c:forEach items="${rootCategoryList}" var="varTemp">
		            <c:choose>
			           <c:when test="${varTemp.isLeaf==0}">
			             <c:choose>
			                <c:when test="${cateIdMap[varTemp.id]!=null}">
		               <li id="${varTemp.id}"  class="parent selected"><span>${varTemp.name}</span></li>
			                </c:when>
			                <c:otherwise>
		               <li id="${varTemp.id}" class="parent"><span>${varTemp.name}</span></li>
			                </c:otherwise>
			             </c:choose>
			           </c:when>
			           <c:otherwise>
			             <c:choose>
			                <c:when test="${cateIdMap[varTemp.id]!=null}">
		               <li id="${varTemp.id}"  class="selected"><span>${varTemp.name}</span></li>
			                </c:when>
			                <c:otherwise>
		               <li id="${varTemp.id}"><span>${varTemp.name}</span></li>
			                </c:otherwise>
			             </c:choose>
			           </c:otherwise>
			        </c:choose>
		        </c:forEach>
		        </ul>
		      </li>
		      <c:forEach items="${map}" var="entry" varStatus="entryStatus">
		         <li id="_o_l_${entryStatus.index+1}">
		           <ul id="_o_l_u_${entryStatus.index+1}">
		         <c:forEach items="${entry.value}" var="varTemp" varStatus="varStatusTemp">
		           <c:choose>
		             <c:when test="${varTemp.isLeaf==0}">
			           <c:choose>
			             <c:when test="${cateIdMap[varTemp.id]!=null}">
			          <li id="${varTemp.id}" class="parent selected"><span>${varTemp.name}${entry.key}</span></li>
			             </c:when>
			             <c:otherwise>
			          <li id="${varTemp.id}" class="parent"><span>${varTemp.name}</span></li>
			             </c:otherwise>
			           </c:choose>
		             </c:when>
		             <c:otherwise>
			           <c:choose>
			             <c:when test="${cateIdMap[varTemp.id]!=null}">
			          <li id="${varTemp.id}" class="selected"><span>${varTemp.name}</span></li>
			             </c:when>
			             <c:otherwise>
			          <li id="${varTemp.id}"><span>${varTemp.name}</span></li>
			             </c:otherwise>
			           </c:choose>
		             </c:otherwise>
		           </c:choose>
		         </c:forEach>
		           </ul>
		         </li>
		      </c:forEach>
		    </ol>
		  </div>  
        </td>
      </tr>
      <tr>
        <td class="label">展现形式：</td>
        <td>
          <select name="displayType" id="displayType" onchange="javascript:onchangeDisplayType(this.value);">
             <option value="${CATEGORY_ATTRIBUTE_DISPLAY_TYPE_INPUTTEXT}">输入框</option>
             <option value="${CATEGORY_ATTRIBUTE_DISPLAY_TYPE_SELECT}">下拉框</option>
             <option value="${CATEGORY_ATTRIBUTE_DISPLAY_TYPE_CHECKBOX}">复选框</option>
          </select>
        </td>
      </tr>
      <tr>
        <td class="label">是否必需属性：</td>
        <td>
          <select name="isNecessary" id="isNecessary">
             <option value="1">是</option>
             <option value="0">否</option>
          </select>
        </td>
      </tr>
      <tr id="candidateTrId" style="display:none;">
        <td class="label">属性候选值：</td>
        <td>
	         <table align="left" width="90%" id="brandModel-table">
				 <tr>  
				    <td>
					<input type="text" size="20" maxlength="32" name="candidateValue"/> 状态 <select name="candidateValueStatus"><option selected="selected" value="1">启用</option><option value="0">停用</option></select>  <a onclick="addCandidateValue()" href="javascript:;" title="添加目录属性可选值">[添加]</a>
		            </td>
				 </tr>
			 </table>
        </td>
      </tr>
      <tr>
        <td class="label">属性描述：</td>
        <td><input type="text" name="desc" id="desc" value=""/></td>
      </tr>
      <!-- 
      <tr>
        <td class="label">排序：</td>
        <td>
          <input type="text" name="sortOrder" id="sortOrder"  value="" size="15" /></td>
      </tr>
       -->
      </table>
      <div class="button-div">
        <input type="submit" id="submitBt" value=" 确定 " />
      </div>
  </form:form>
</div>
</body>
</html>